﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LdapLogiSeznam.aspx.cs" Inherits="Sio.Mdm.Web.Instalacija.LdapLogiSeznam" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>                
</head>
<body>
    <form id="form1" runat="server">
    <script type="text/javascript">

        function renderDateTime(value) {
            return value.format('d.m.Y G:i');
        }

        var iconStatusSuccess = '<%=ResourceManager1.GetIconUrl(Icon.BulletTick)%>'
        var iconStatusWarning = '<%=ResourceManager1.GetIconUrl(Icon.BulletError)%>'
        var iconStatusError = '<%=ResourceManager1.GetIconUrl(Icon.BulletCross)%>'

        function renderStatusIcon(value) {
            switch (value) {
                case 0:
                    return String.format('<img src="{0}"/>', iconStatusSuccess);
                case 1:
                    return String.format('<img src="{0}"/>', iconStatusWarning);
                case 2:
                    return String.format('<img src="{0}"/>', iconStatusError);
            }
        }

        function PrepareParamsAndShowDialog(eventId, grid, dialog) {

            if (eventId == 'View') {
                var id = getSelectedLogID(grid);
                if (id > 0) {
                    dialog.addParameter('LogID', id);
                    dialog.show();
                }
            }
        }

        function getSelectedLogID(grid) {
            if (grid.getSelectionModel().selections.length == 1) {
                var id = grid.getSelectionModel().selections.items[0].id;
                return id;
            }
            else { return 0; }
        }

        function setButtons() {
            btnEdit.setDisabled(false);
            btnRemove.setDisabled(false);
        }
        
        </script>
    
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
    <ext:Viewport ID="Viewport1" runat="server" Layout="Fit">
    <Content>
        <sio:GridPanel ID="GridLogiSeznam" runat="server" StripeRows="true" TrackMouseOver="true" AutoExpandColumn="Porocilo">                
                <Store>
                    <ext:Store ID="StoreLogiSeznam" runat="server">
                        <Reader>
                            <ext:JsonReader IDProperty="LdapLogID">
                                <Fields>
                                    <ext:RecordField Name="LdapLogID" Type="Int" />
                                    <ext:RecordField Name="LdapPraviloID" Type="Int" />
                                    <ext:RecordField Name="LdapStreznikID" Type="Int" />
                                    
                                    <ext:RecordField Name="Status" Type="Int" />
                                    <ext:RecordField Name="CountIns" Type="Int" />
                                    <ext:RecordField Name="CountUpd" Type="Int" />
                                    <ext:RecordField Name="CountDel" Type="Int" />                                    
                                    <ext:RecordField Name="Porocilo" Type="String" />
                                    <ext:RecordField Name="Opozorilo" Type="String" />
                                    <ext:RecordField Name="Napaka" Type="String" />
                                    <ext:RecordField Name="PorabljenCas" Type="Int" />
                                    <ext:RecordField Name="Datum" Type="Date" /> 
                                    
                                    <ext:RecordField Name="PraviloIme" Type="String" />
                                    <ext:RecordField Name="PraviloOpis" Type="String" />
                                    <ext:RecordField Name="PraviloBaseDN" Type="String" />
                                    <ext:RecordField Name="StreznikIme" Type="String" />
                                    <ext:RecordField Name="StreznikOpis" Type="String" />
                                    <ext:RecordField Name="StreznikNaslov" Type="String" />
                                    <ext:RecordField Name="StreznikRootDN" Type="String" />
                                    <ext:RecordField Name="OrgarnizacijaNaziv" Type="String" />                                                                                                           
                                </Fields>
                            </ext:JsonReader>                            
                        </Reader>                        
                    </ext:Store>
                </Store>
                    <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column ColumnID="LdapLogID" Hidden="true" Hideable="true" DataIndex="LdapStreznikID" Header="LdapLogID">
                        </ext:Column>
                        <ext:Column ColumnID="Organizacija" Hidden="false" Hideable="true" DataIndex="OrgarnizacijaNaziv" Header="Organizacija" Width="150">
                        </ext:Column>
                        <ext:Column ColumnID="LdapPraviloID" Hidden="true" Hideable="true" DataIndex="LdapPraviloID" Header="LdapPraviloID">
                        </ext:Column>
                        <ext:Column ColumnID="LdapStreznikID" Hidden="true" Hideable="true" DataIndex="LdapStreznikID" Header="LdapStreznikID">
                        </ext:Column>
                        <ext:Column ColumnID="Status" Hidden="false" Hideable="false" DataIndex="Status" Header="Status" Width="50">
                            <Renderer Fn="renderStatusIcon" />                            
                        </ext:Column>                                                                         
                        <ext:Column ColumnID="PraviloIme" Hidden="false" Hideable="false" DataIndex="PraviloIme" Header="Pravilo Ime" Width="150">
                        </ext:Column>
                        <ext:Column ColumnID="PraviloOpis" Hidden="false" Hideable="true" DataIndex="PraviloOpis" Header="Pravilo Opis" Width="150">
                        </ext:Column>
                        <ext:Column ColumnID="StreznikIme" Hidden="false" Hideable="true" DataIndex="StreznikIme" Header="Streznik Ime">
                        </ext:Column>
                        <ext:Column ColumnID="Porocilo" Hidden="false" Hideable="false" DataIndex="Porocilo" Header="Poročilo">
                        </ext:Column> 
                        <ext:Column ColumnID="Datum" Hidden="false" Hideable="false" DataIndex="Datum" Header="Datum">
                            <Renderer Fn="renderDateTime" />
                        </ext:Column>
                        <ext:Column ColumnID="PorabljenCas" Hidden="false" Hideable="true" DataIndex="PorabljenCas" Header="Čas [s]" Width="50" Tooltip="Čas trajanja operacije v [s]" >
                        </ext:Column> 
                        <ext:Column ColumnID="CountIns" Hidden="false" Hideable="false" DataIndex="CountIns" Header="N" Width="30" Tooltip="Število dodanih / Novih  zapisov">
                        </ext:Column>
                        <ext:Column ColumnID="CountUpd" Hidden="false" Hideable="false" DataIndex="CountUpd" Header="P" Width="30" Tooltip="Število Posodobljenih zapisov">
                        </ext:Column>
                        <ext:Column ColumnID="CountDel" Hidden="false" Hideable="false" DataIndex="CountDel" Header="B" Width="30" Tooltip="Število Brisanih zapisov">
                        </ext:Column>                                                                                                                                                        
                    </Columns>
                </ColumnModel>
                <SelectionModel>                                                            
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server">
						<Listeners>
							<RowSelect Handler="setButtons();" />
						</Listeners>
					</ext:RowSelectionModel>					
                </SelectionModel>
                <TopBar>
                <ext:Toolbar ID="Toolbar1" runat="server">
                <Items>                    
                    <sio:Button runat="server" ID="btnEdit" Text="Pregled" Icon="Note" Disabled="true">                                
                        <Listeners>
                            <Click Handler="PrepareParamsAndShowDialog('View',#{GridLogiSeznam},#{DialogLogiPodrobno});" />
                        </Listeners>
                    </sio:Button>
                    <sio:Button runat="server" ID="btnRemove" Text="Odstrani" Icon="Delete" Disabled="true">
                        <DirectEvents>
                            <Click OnEvent="OdstraniZapise">
                                <Confirmation ConfirmRequest="true" Message="Odstranim izbrane zapise?" />
                                <ExtraParams>
                                    <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridLogiSeznam}.getRowsValues({selectedOnly:true}))" />
                                </ExtraParams>
                            </Click>
                        </DirectEvents>
                    </sio:Button>                    
                    <ext:ToolbarSeparator />                    
                 </Items>
                </ext:Toolbar>
                </TopBar>
         </sio:GridPanel>
    
    </Content>
    </ext:Viewport>
    
    <sio:Dialog runat="server" ID="DialogLogiPodrobno"
		Width="750"
		Height="500"
		Url="LdapLogiPodrobno.aspx"
		DialogButtons="Close"
    Title="Log Podrobno">
        <Parameters>
			<ext:Parameter Name="LogID" Value="x" Mode="Value" />			
		</Parameters>
		<Listeners>
            
        </Listeners>
	</sio:Dialog>
    </form>
</body>
</html>
